package com.log.controller;

import com.log.model.dto.LogInfoDTO;
import com.log.service.LogInfoService;
import com.log.util.JsonData;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Description TODO
 * @Author zhaoYi
 * @Date 2024/7/14 22:38
 */


@RequestMapping("/log/sync")
@RestController
@RequiredArgsConstructor
public class LogInfoController {

    private final LogInfoService syncLogService;

    @ApiOperation("同步新增日志")
    @PostMapping("insert")
    public JsonData syncAndInsertLog(@RequestBody List<LogInfoDTO> dtoList) {

        JsonData jsonData = syncLogService.syncAndInsertLog(dtoList);

        return JsonData.buildSuccess(jsonData);
    }

    @ApiOperation("分页查询日志列表")
    @PostMapping("page")
    public JsonData getPage(@RequestBody LogInfoDTO logInfoDTO) {

        Map<String, Object> pageResult = syncLogService.getPage(logInfoDTO);

        return JsonData.buildSuccess(pageResult);


    }
}
